package com.xcf.service.business.consign.impl;
import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Types;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.CallableStatementCreator;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.core.SqlOutParameter;
import org.springframework.jdbc.core.SqlParameter;
import org.springframework.stereotype.Service;

import com.alibaba.fastjson.JSONObject;
import com.xcf.dao.DaoSupport;
import com.xcf.entity.Page;
import com.xcf.service.business.consign.ConsignInputService;
import com.xcf.util.PageData;



@Service("ConsignInputServiceImpl")
public class ConsignInputServiceImpl implements ConsignInputService {
	
@Resource(name="daoSupport")
private  DaoSupport daosuport;

	@SuppressWarnings("unchecked")
	@Override
	public List<PageData> getTradeListForImport(Page page)throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.tradelistPage", page);
	}
	@Override
	public  List<PageData> getSalesPerson(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.saleslistPage", page);
	}
	@Override
	public  List<PageData> getCustomer(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.cutomerlistPage", page);
	}

	@Override
	public  List<PageData> getBoxMaster(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.boxMasterlistPage", page);		
	}
	@Override
	public  List<PageData> getGoodsSourceCombo(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.getGoodsSourceCombo", page);			
	}
	@Override
	public List<PageData> getInlandHarbor(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.inlandHarborlistPage", page);	
	}
	
	@Override
	public List<PageData> getForeignHarbour(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.foreignHarbourlistPage", page);
	}
	
	
	@Override
	public List<PageData> getCountryNames(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.countryNameslistPage", page);	
	}
	
	
	@Override
	public List<PageData> getGoodsSource(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.goodsSourceCombolistPage", page);
	}	
	
	@Override
	public List<PageData> getTradeInfo(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.tradeInfolistPage", page);
	}
	
	@Override
	public Object getUserId(Page page) throws Exception{
		return   daosuport.findForObject("ConsignInputMapper.useridPage", page);	

	}
	
	@Override
	public Object queryBillCode(PageData pd){
		try {
			return daosuport.findForObject("ConsignInputMapper.queryBillCode", pd);
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return null;
	}
	@Override
	public String consignUpdate(PageData pd){
		 try{
		      daosuport.save("ConsignInputMapper.consignUpdate", pd);
		      return "1";
		  }catch(Exception ex)
		  {
			  ex.printStackTrace();
			  return "-1";
		  }
	}
	@Override
	public String consignAdd(PageData pd) {
		  try{
		      daosuport.save("ConsignInputMapper.consignSave", pd);
		      return "1";
		  }catch(Exception ex)
		  {
			  ex.printStackTrace();
			  return "-1";
		  }
	}
	
	@Override
	public List<PageData> getGoodsTypeName(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.goodsTypeNamelistPage", page);
	}
	
	@Override
	public List<PageData> getDangerous(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.dangerouslistPage", page);
	}
	
	@Override
	public List<PageData> getCustomsClearance(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.customsClearancelistPage", page);
	}
	
	@Override
	public List<PageData> getGateUnit(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.gateUnitlistPage", page);
	}
	
	
	@Override
	public List<PageData> getBolType(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.bolTypelistPage", page);
	}
	
	@Override
	public List<PageData> getPackaging(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.packaginglistPage", page);
	}
	@Override
	public List<PageData> getBoxType(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.boxTypelistPage", page);
	}
	
	@Override
	public List<PageData> getTransportItem(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.transportItemlistPage", page);
	}
	@Override
	public List<PageData> getSupplierList(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.supplierlistPage", page);
	}
	
	@Override
	public List<PageData> getTrailerInfo(Page page) throws Exception{
		return (List<PageData>) daosuport.findForList("ConsignInputMapper.trailerInfolistPage", page);
	}
	
	
    public Object getFlowNumber(Map<String, String> param) throws Exception{
    	return  daosuport.findForObject("ConsignInputMapper.getFlowNumber", param);    	
    }
	
    @Override
    public void trailerUpdate(List<Map<String,String>> list) throws Exception
    {
     	  daosuport.save("ConsignInputMapper.trailerUpdate",list);
    }
    @Override
    public void consignFlowNumUpdate(Map<String, String> param) throws Exception
    {
    	
    	daosuport.save("ConsignInputMapper.consignFlowNumUpdate",param); 
    
    }
    @Override
    public void boxtypeNumInsert(List<Map<String,String>> list) throws Exception
    {
    	daosuport.batchSave("ConsignInputMapper.boxtypeNumInsert",list); 
    }
    @Override
	public PageData selectDangerous(PageData pd) throws Exception{
		return (PageData)daosuport.findForObject("ConsignInputMapper.selectDangerous", pd);
	}
    @Override
    public int getTrailerNum(Map<String,String> map) throws Exception
    {
    	//Mapped Statements collection does not contain value for ConsignInputMapper.getTrailerNum
     	return (int)daosuport.findForObject("ConsignInputMapper.getTrailerNum", map);
    }
    @Override
    public void trailerInsert(List<Map<String,String>> list) throws Exception{
    	daosuport.batchSave("ConsignInputMapper.trailerInsert",list); 
    }
    @Override
    public void deleteTrailer(Map<String, String> param) throws Exception{
    	daosuport.save("ConsignInputMapper.deleteTrailer",param); 
    }
	@Override
	public String getNameById(Object id) throws Exception {
		//Integer ID = Integer.parseInt(id.toString().trim());
		return (String) daosuport.findForObject("ConsignInputMapper.getNameById",Integer.parseInt(id.toString()));
	}
	@Override
	public String getBoxMasterNameById(String idField) throws Exception {
		return (String) daosuport.findForObject("ConsignInputMapper.getBoxMasterNameById",Integer.parseInt(idField));
	}
	@Override
	public String getPortOfDischargeNameById(String idField) throws Exception  {
		// TODO Auto-generated method stub
		return(String) daosuport.findForObject("ConsignInputMapper.getPortOfDischargeNameById",Integer.parseInt(idField));
	}
	@Override
	public String getStopHarbourNameById(String keyword) throws Exception  {
		// TODO Auto-generated method stub
		return (String)daosuport.findForObject("ConsignInputMapper.getStopHarbourNameById",keyword);
	}
	@Override
	public String getTransportItemNameById(String idField) throws Exception {
		// TODO Auto-generated method stub
		return (String)daosuport.findForObject("ConsignInputMapper.getTransportItemNameById", Integer.parseInt(idField));
	}
	@Override
	public String getAgencyManNameById(String idField) throws Exception {
		// TODO Auto-generated method stub
		return (String)daosuport.findForObject("ConsignInputMapper.getAgencyManNameById",Integer.parseInt(idField));
	}
	@Override
	public String getBolTypeNameById(String idField) throws Exception {
		// TODO Auto-generated method stub
		return (String)daosuport.findForObject("ConsignInputMapper.getBolTypeNameById", Integer.parseInt(idField));
	}
	@Override
	public String getGateUnitNameById(String idField) throws Exception {
		// TODO Auto-generated method stub
		return (String)daosuport.findForObject("ConsignInputMapper.getGateUnitNameById", Integer.parseInt(idField));
	}
	@Override
	public String getPlaceOfDeliveryNameById(String idField) throws Exception {
		// TODO Auto-generated method stub
		return (String)daosuport.findForObject("ConsignInputMapper.getPlaceOfDeliveryNameById",Integer.parseInt(idField));
	}

	
	
	
	

	

}
